﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class aspnet_admin_loginState_LoginStateView : System.Web.UI.Page
{
    Tong.TongUse TextData = new Tong.TongUse();
    protected void Page_Load(object sender, EventArgs e)
    {
        BindData();
    }


    //看看是不是要删除数据
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");

            l.Attributes.Add("onclick", "javascript:return " +

            "confirm('您确定要删除 " +

            DataBinder.Eval(e.Row.DataItem, "CX_loginState_ActionInfo") + "吗?')");

        }

    }

    protected void BindData()
    {
        DataTable TempTab = new DataTable();
        TempTab = TextData.SqlataSet("SELECT * FROM [CX_loginState] order by CX_loginState_id desc").Tables[0];
        GridView1.DataSource = TempTab.DefaultView;
        GridView1.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        GridView1.DataSource = TextData.SqlataSet("select * from [CX_loginState]  where CX_loginState_uid like '%" + Cx_keyWord_Name.Text.Trim() + "%' order by CX_loginState_id desc").Tables[0].DefaultView;
        GridView1.PageSize = 50000;
        GridView1.DataBind();
    } 

    /// <summary>
    /// 分页
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void pagechange(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataSource = TextData.SqlataSet("SELECT * FROM [CX_loginState] order by CX_loginState_id desc").Tables[0].DefaultView;

        GridView1.DataBind();
    }

    /// <summary>
    /// 删除事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void delcc(object sender, EventArgs e)
    {

        string RedirID = ((LinkButton)sender).CommandArgument.ToString();
        if (RedirID != "")
        {
            try
            {
                TextData.SqlDataSave("delete [CX_loginState] where CX_loginState_id = " + RedirID);
                tt.Text = "";
                tt.Text = "删除 信息成功";
                BindData();
            }
            catch
            {
                tt.Text = "";
                tt.Text = "删除  时出现错误　操作没有完成 ";
            }
        }

    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        TextData.SqlDataSave("delete [CX_loginState]");
        tt.Text = "删除所有成功";
        BindData();
    }
}
